home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ShareWare OnLine 2
/
ShareWare OnLine Volume 2 (CMS Software)(1993).iso
/
prog
/
spx10.zip
/
SPX_DOC.ZIP
/
SPX_EFF.DOC
next >
Wrap
Text File
|
1993-05-05
|
6KB
|
182 lines
{ SPX Library Version 1.0 Copyright 1993 Scott D. Ramsay }
SPX_EFF is the background effects unit. It allows for special effect
for backgrounds. Such as parallax scrolling and background panning.
In effect the unit SPX_EFF is an enhanced version of a page copy routine.
It does a 'warped' or modified copy from one page to another.
See DEMO1.PAS for code example
───────────────────────────────────────────────────────────────────────────
type
Pcycle = ^Tcycle;
Tcycle = object
Tcycle is the main effects object. There are many variables that effect
the way one can display a background.
VARIABLES:
cyc_next: The current value of the frequency counter. By defalt its
resolution changes every line drawn from 0..wmax-1;
from_x: Left (X) position of the source page to copy;
from_y: Top (Y) position of the source page to copy;
cyc_x: Left (X) position of the destination page;
cyc_y: Top (Y) position of the destination page;
cyc_width: Width of the region to copy;
cyc_height: Height of the region to copy;
cycley: Pan (Y) offset position. Value should be 0..cyc_height-1;
cyclex: Pan (X) offset position. Value should be 0..cyc_width-1;
fr_size: Calcuated frequency size. (Used for cosine copies);
am_size: Amplitude size of cosine wave;
cycle_cos: Cosine table
---------------------------------------------------
constructor Tcycle.init(freq,size:integer);
Sets up the object.
FREQ: Frequency for cosine wave;
SIZE: Cosine wave height (Amplitude)
DEFAULTS:
CYCLEX 0
CYCLEY 0
CYC_WIDTH 320
CYC_HEIGHT 200
---------------------------------------------------
destructor Tcycle.done;virtual;
Preforms and deallocation of the object;
---------------------------------------------------
procedure Tcycle.changewave(freq,size:integer);virtual;
Changes the cosine table.
FREQ: Frequency for cosine wave;
SIZE: Cosine wave height (Amplitude)
---------------------------------------------------
procedure Tcycle.docycle(from,too,mode:byte); virtual;
Preforms an effect copy.
FROM: Source page to copy;
TOO: Destination page;
MODE: Type of copy
0 Regular copy
1 Regular copy with panning
2 Cosine wave copy
3 User defined copy
When setting the mode to 3, a call to usercycle is made for each
iteration of a horzontal line copied. See procedure "usercycle" below.
---------------------------------------------------
procedure Tcycle.cycle_move; virtual;
Pan procedure. Updates the cyclex and cycley variables.
OVERRIDE: often
Use this procedure to update the panning coordintes. The pan
coordinates are often linked to the player's user position to
create background motion.
---------------------------------------------------
procedure Tcycle.adjustcyclenext; virtual;
Modifies the cyc_next variable.
OVERRIDE: seldom.
───────────────────────────────────────────────────────────────────────────
type
usercp = procedure (f,t,yline:longint);
var
usercycle : usercp; { user cycle procedure }
When Tcycle.docycle is called with mode=3, usercycle is called. You must
define your own procedure and assign it to usercycle so that docycle will
call your procedure.
procedure MyCycleLine(f,t,yline:longint);far;
begin
end;
.
.
.
usercycle := MyCycleLine;
Note that MyCycleLine must be declared as a far procedure and has the
same parameter list as usercp type.
usercycle takes three arguments:
F: Pointer to the source page
T: Pointer to the destination page
YLINE: Current row being displayed.
To use F or T, typecast it as as a pointer. e.g.
move(pointer(f)^,pointer(t)^,20); { copy 20 bytes }
───────────────────────────────────────────────────────────────────────────
procedure linemove(s,d:longint;cnt:word);
Copies a segment of bytes from S to D.
S: Pointer to source;
D: Pointer to destination;
CNT: Number of byte to move
───────────────────────────────────────────────────────────────────────────
procedure wordmove(var source,dest;cnt:word);
Copies a segment of bytes from S to D.
S: Pointer to source;
D: Pointer to destination;
CNT: Number of byte to move
Uses word copies, use only if cnt is an even number.
───────────────────────────────────────────────────────────────────────────
procedure cycleline(f,t:longint;cyclex,cycle_width:word);
Copies a segment of bytes from F to T. wraping the bytes if needed.
F: Pointer to source;
T: Pointer to destination;
cyclex: Offset in destination;
cycle_width Width of destination
Example:
F=source T=Destination cyclex=4 cycle_width=8
┌──┬──┬──┬──┬──┬──┬──┬──┐
F │ 1│ 2│ 3│ 4│ 5│ 6│ 7│ 8│
└──┴──┴──┴──┴──┴──┴──┴──┘
┌──┬──┬──┬──┬──┬──┬──┬──┐
T │ 5│ 6│ 7│ 8│ 1│ 2│ 3│ 4│
└──┴──┴──┴──┴──┴──┴──┴──┘
F=source T=Destination cyclex=0 cycle_width=8
┌──┬──┬──┬──┬──┬──┬──┬──┐
F │ 1│ 2│ 3│ 4│ 5│ 6│ 7│ 8│
└──┴──┴──┴──┴──┴──┴──┴──┘
┌──┬──┬──┬──┬──┬──┬──┬──┐
T │ 1│ 2│ 3│ 4│ 5│ 6│ 7│ 8│
└──┴──┴──┴──┴──┴──┴──┴──┘
───────────────────────────────────────────────────────────────────────────